﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using TakeoutExpress.Support.Linq;
using TakeoutExpress.Support.Controllers;

namespace TakeoutExpress2008.Web.MVC.Admin
{
    public partial class AudienceEditor : Components.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AudienceController controller = new AudienceController();
            this.gvAudiences.RowDataBound += new GridViewRowEventHandler(gvAudiences_RowDataBound);
            gvAudiences.DataSource = controller.GetSiteAudiences(SiteID);
        }

        void gvAudiences_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // find the sites listview to bind
            Audience audience = (Audience)e.Row.DataItem;
            ListView lvSites = (ListView)e.Row.FindControl("lvSites");
            if (lvSites != null)
            {
                lvSites.DataSource = audience.Site;
                lvSites.DataBind();
            }
        }
    }
}
